<?php
	if(empty($_REQUEST['lang'])){
		$url = "http://".$_SERVER ['HTTP_HOST'].$_SERVER['PHP_SELF'];
		header("Location: ".$url."?lang=sc");
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>后台</title>
    <link href="./css/default.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="./themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="./themes/icon.css" />
    <script type="text/javascript" src="./js/jquery-1.6.2.min.js"></script>
    <script type="text/javascript" src="./js/jquery.easyui.min.js"></script>
	<?php
		if ($_REQUEST['lang'] == 'sc'){
			echo "<script type='text/javascript' src='./js/locale/easyui-lang-zh_CN.js'></script>";
		}else if ($_REQUEST['lang'] == 'tc'){
			echo "<script type='text/javascript' src='./js/locale/easyui-lang-zh_TW.js'></script>";
		}else{
			echo "<script type='text/javascript' src='./js/locale/easyui-lang-zh_CN.js'></script>";
		}
	?>
	<script type="text/javascript">
		$(document).ready(function(){
		<?php
			if ($_REQUEST['lang'] == 'sc'){
				echo 'var _menus = {"menus":[
							{"menuid":"0","icon":"icon-sys","menuname":"首页及新闻四格",
								"menus":[
										{"menuid":"01","menuname":"新增","icon":"icon-add","url":"uploadimg.php?lang=sc&action=new"},
										{"menuid":"02","menuname":"列表","icon":"icon-users","url":"listimg.php?lang=sc"}
									]
							},{"menuid":"1","icon":"icon-sys","menuname":"公司概况",
								"menus":[
										{"menuid":"12","menuname":"公司简介","icon":"icon-add","url":"editor.php?lang=sc&part=cp&action=view"},
										{"menuid":"13","menuname":"公司理念","icon":"icon-users","url":"editor.php?lang=sc&part=ph&action=view"},
										{"menuid":"14","menuname":"管理团队","icon":"icon-role","url":"editor.php?lang=sc&part=mt&action=view"},
										{"menuid":"15","menuname":"资质荣誉","icon":"icon-set","url":"editor.php?lang=sc&part=ho&action=view"}
									]
							},{"menuid":"2","icon":"icon-sys","menuname":"新闻信息",
								"menus":[{"menuid":"21","menuname":"新增新闻","icon":"icon-add","url":"editor.php?lang=sc&part=news&action=new"},
										{"menuid":"22","menuname":"新闻列表","icon":"icon-nav","url":"list.php?lang=sc&part=news"}
									]
							},{"menuid":"3","icon":"icon-sys","menuname":"专业服务",
								"menus":[{"menuid":"31","menuname":"新增服务","icon":"icon-add","url":"editor.php?lang=sc&part=services&action=new"},
										{"menuid":"32","menuname":"服务列表","icon":"icon-nav","url":"list.php?lang=sc&part=services"}
									]
							},{"menuid":"4","icon":"icon-sys","menuname":"项目介绍",
								"menus":[{"menuid":"41","menuname":"新增项目","icon":"icon-add","url":"editor.php?lang=sc&part=projects&action=new"},
										{"menuid":"42","menuname":"项目列表","icon":"icon-nav","url":"list.php?lang=sc&part=projects"}
									]
							},{"menuid":"5","icon":"icon-sys","menuname":"合作伙伴",
								"menus":[{"menuid":"51","menuname":"合作伙伴","icon":"icon-nav","url":"editor.php?lang=sc&part=bi&action=view"},
										{"menuid":"61","menuname":"联系我们","icon":"icon-nav","url":"editor.php?lang=sc&part=cu&action=view"},
										{"menuid":"62","menuname":"网站地图","icon":"icon-nav","url":"editor.php?lang=sc&part=sm&action=view"},
										{"menuid":"63","menuname":"法律声明","icon":"icon-nav","url":"editor.php?lang=sc&part=ln&action=view"},
										{"menuid":"64","menuname":"友情链接","icon":"icon-nav","url":"editor.php?lang=sc&part=li&action=view"}
									]
							}
					]};';
			}else if ($_REQUEST['lang'] == 'tc'){
				echo 'var _menus = {"menus":[
							{"menuid":"0","icon":"icon-sys","menuname":"首頁及新聞四格",
								"menus":[
										{"menuid":"01","menuname":"新增","icon":"icon-add","url":"uploadimg.php?lang=tc&action=new"},
										{"menuid":"02","menuname":"列表","icon":"icon-users","url":"listimg.php?lang=tc"}
									]
							},{"menuid":"1","icon":"icon-sys","menuname":"公司概況",
								"menus":[
										{"menuid":"12","menuname":"公司簡介","icon":"icon-add","url":"editor.php?lang=tc&part=cp&action=view"},
										{"menuid":"13","menuname":"公司理念","icon":"icon-users","url":"editor.php?lang=tc&part=ph&action=view"},
										{"menuid":"14","menuname":"管理團隊","icon":"icon-role","url":"editor.php?lang=tc&part=mt&action=view"},
										{"menuid":"15","menuname":"資質榮譽","icon":"icon-set","url":"editor.php?lang=tc&part=ho&action=view"}
									]
							},{"menuid":"2","icon":"icon-sys","menuname":"新聞信息",
								"menus":[{"menuid":"21","menuname":"新增新聞","icon":"icon-add","url":"editor.php?lang=tc&part=news&action=new"},
										{"menuid":"22","menuname":"新聞列表","icon":"icon-nav","url":"list.php?lang=tc&part=news"}
									]
							},{"menuid":"3","icon":"icon-sys","menuname":"專業服務",
								"menus":[{"menuid":"31","menuname":"新增服務","icon":"icon-add","url":"editor.php?lang=tc&part=services&action=new"},
										{"menuid":"32","menuname":"服務列表","icon":"icon-nav","url":"list.php?lang=tc&part=services"}
									]
							},{"menuid":"4","icon":"icon-sys","menuname":"項目介紹",
								"menus":[{"menuid":"41","menuname":"新增項目","icon":"icon-add","url":"editor.php?lang=tc&part=projects&action=new"},
										{"menuid":"42","menuname":"項目列表","icon":"icon-nav","url":"list.php?lang=tc&part=projects"}
									]
							},{"menuid":"5","icon":"icon-sys","menuname":"合作夥伴",
								"menus":[{"menuid":"51","menuname":"合作夥伴","icon":"icon-nav","url":"editor.php?lang=tc&part=bi&action=view"},
										{"menuid":"61","menuname":"聯系我們","icon":"icon-nav","url":"editor.php?lang=tc&part=cu&action=view"},
										{"menuid":"62","menuname":"網站地圖","icon":"icon-nav","url":"editor.php?lang=tc&part=sm&action=view"},
										{"menuid":"63","menuname":"法律聲明","icon":"icon-nav","url":"editor.php?lang=tc&part=ln&action=view"},
										{"menuid":"64","menuname":"友情鏈接","icon":"icon-nav","url":"editor.php?lang=tc&part=li&action=view"}
									]
							}
					]};';
			}else{
				echo 'var _menus = {"menus":[
							{"menuid":"0","icon":"icon-sys","menuname":"首页及新闻四格",
								"menus":[
										{"menuid":"01","menuname":"新增","icon":"icon-add","url":"uploadimg.php?lang=sc&action=new"},
										{"menuid":"02","menuname":"列表","icon":"icon-users","url":"listimg.php?lang=sc"}
									]
							},{"menuid":"1","icon":"icon-sys","menuname":"公司概况",
								"menus":[
										{"menuid":"11","menuname":"公司简介","icon":"icon-add","url":"editor.php?lang=sc&part=cp&action=view"},
										{"menuid":"12","menuname":"公司理念","icon":"icon-users","url":"editor.php?lang=sc&part=ph&action=view"},
										{"menuid":"13","menuname":"管理团队","icon":"icon-role","url":"editor.php?lang=sc&part=mt&action=view"},
										{"menuid":"14","menuname":"资质荣誉","icon":"icon-set","url":"editor.php?lang=sc&part=ho&action=view"}
									]
							},{"menuid":"2","icon":"icon-sys","menuname":"新闻信息",
								"menus":[{"menuid":"21","menuname":"新增新闻","icon":"icon-add","url":"editor.php?lang=sc&part=news&action=new"},
										{"menuid":"22","menuname":"新闻列表","icon":"icon-nav","url":"list.php?lang=sc&part=news"}
									]
							},{"menuid":"3","icon":"icon-sys","menuname":"专业服务",
								"menus":[{"menuid":"31","menuname":"新增服务","icon":"icon-add","url":"editor.php?lang=sc&part=services&action=new"},
										{"menuid":"32","menuname":"服务列表","icon":"icon-nav","url":"list.php?lang=sc&part=services"}
									]
							},{"menuid":"4","icon":"icon-sys","menuname":"项目介绍",
								"menus":[{"menuid":"41","menuname":"新增项目","icon":"icon-add","url":"editor.php?lang=sc&part=projects&action=new"},
										{"menuid":"42","menuname":"项目列表","icon":"icon-nav","url":"list.php?lang=sc&part=projects"}
									]
							},{"menuid":"5","icon":"icon-sys","menuname":"合作伙伴",
								"menus":[{"menuid":"51","menuname":"合作伙伴","icon":"icon-nav","url":"editor.php?lang=sc&part=bi&action=view"},
										{"menuid":"61","menuname":"联系我们","icon":"icon-nav","url":"editor.php?lang=sc&part=cu&action=view"},
										{"menuid":"62","menuname":"网站地图","icon":"icon-nav","url":"editor.php?lang=sc&part=sm&action=view"},
										{"menuid":"63","menuname":"法律声明","icon":"icon-nav","url":"editor.php?lang=sc&part=ln&action=view"},
										{"menuid":"64","menuname":"友情链接","icon":"icon-nav","url":"editor.php?lang=sc&part=li&action=view"}
									]
							}
					]};';
			}
		?>
		function login(){
			$('#login-win').window({
				collapsible:false,
				minimizable:false,
				maximizable:false,
				closable:false,
				closed:false,
				draggable:false,
				resizable:false,
				shadow:true,
				inline:false,
				modal:true
			});
			$('#login_ok').linkbutton({
				text:'确定',
				iconCls:'icon-ok'
			});
			$.ajax({
			  url: "/interface.php",
			  async: true,
			  type:'POST',
			  dataType:'json',
			  data:{type:'has_login'},
			  success: function(msg){
				if (msg == 'success'){
					$('#login-win').window('close');
				}
			  }
			});
		}
		function InitLeftMenu() {
			$("#west-menu").accordion({animate:true,fit:true});
			$.each(_menus.menus, function(i, n) {
				var menulist ='';
				menulist +='<ul>';
				$.each(n.menus, function(j, o) {
					menulist += '<li><div><a ref="'+o.menuid+'" href="#" rel="' + o.url + '" ><span id="icon" class="icon '+o.icon+'" >&nbsp;</span><span class="nav">' + o.menuname + '</span></a></div></li> ';
				})
				menulist += '</ul>';

				$('#west-menu').accordion('add', {
					title: n.menuname,
					content: menulist,
					iconCls: 'icon ' + n.icon
				});

			});

			$('.easyui-accordion li a').click(function(){
				var tabTitle = $(this).children('.nav').text();

				var url = $(this).attr("rel");
				var menuid = $(this).attr("ref");
				//var icon = $(this).children('#icon').attr('class');
				var icon = getIcon(menuid);

				addTab(tabTitle,url,icon);
				$('.easyui-accordion li div').removeClass("selected");
				$(this).parent().addClass("selected");
			}).hover(function(){
				$(this).parent().addClass("hover");
			},function(){
				$(this).parent().removeClass("hover");
			});

			//选中第一个
			var panels = $('#west-menu').accordion('panels');
			var t = panels[0].panel('options').title;
			$('#west-menu').accordion('select', t);
		}
		
		function addTab(subtitle,url,icon){
			if(!$('#tabs').tabs('exists',subtitle)){
				$('#tabs').tabs('add',{
					title:subtitle,
					content:createFrame(url),
					closable:true,
					icon:icon
				});
			}else{
				$('#tabs').tabs('select',subtitle);
				$('#mm-tabupdate').click();
			}
			tabClose();
		}
		
		function createFrame(url)
		{
			var s = '<iframe scrolling="auto" frameborder="0"  src="'+url+'" style="width:100%;height:100%;"></iframe>';
			return s;
		}
		
		function tabClose()
		{
			/*双击关闭TAB选项卡*/
			$(".tabs-inner").dblclick(function(){
				var subtitle = $(this).children(".tabs-closable").text();
				$('#tabs').tabs('close',subtitle);
			})
			/*为选项卡绑定右键*/
			$(".tabs-inner").bind('contextmenu',function(e){
				$('#mm').menu('show', {
					left: e.pageX,
					top: e.pageY
				});

				var subtitle =$(this).children(".tabs-closable").text();

				$('#mm').data("currtab",subtitle);
				$('#tabs').tabs('select',subtitle);
				return false;
			});
		}
		
		//绑定右键菜单事件
		function tabCloseEven()
		{
			//刷新
			$('#mm-tabupdate').click(function(){
				var currTab = $('#tabs').tabs('getSelected');
				var url = $(currTab.panel('options').content).attr('src');
				$('#tabs').tabs('update',{
					tab:currTab,
					options:{
						content:createFrame(url)
					}
				})
			})
			//关闭当前
			$('#mm-tabclose').click(function(){
				var currtab_title = $('#mm').data("currtab");
				$('#tabs').tabs('close',currtab_title);
			})
			//全部关闭
			$('#mm-tabcloseall').click(function(){
				$('.tabs-inner span').each(function(i,n){
					var t = $(n).text();
					$('#tabs').tabs('close',t);
				});
			});
			//关闭除当前之外的TAB
			$('#mm-tabcloseother').click(function(){
				$('#mm-tabcloseright').click();
				$('#mm-tabcloseleft').click();
			});
			//关闭当前右侧的TAB
			$('#mm-tabcloseright').click(function(){
				var nextall = $('.tabs-selected').nextAll();
				if(nextall.length==0){
					return false;
				}
				nextall.each(function(i,n){
					var t=$('a:eq(0) span',$(n)).text();
					$('#tabs').tabs('close',t);
				});
				return false;
			});
			//关闭当前左侧的TAB
			$('#mm-tabcloseleft').click(function(){
				var prevall = $('.tabs-selected').prevAll();
				if(prevall.length==0){
					return false;
				}
				prevall.each(function(i,n){
					var t=$('a:eq(0) span',$(n)).text();
					$('#tabs').tabs('close',t);
				});
				return false;
			});

			//退出
			$("#mm-exit").click(function(){
				$('#mm').menu('hide');
			})
		}
		
		//获取左侧导航的图标
		function getIcon(menuid){
			var icon = 'icon ';
			$.each(_menus.menus, function(i, n) {
				 $.each(n.menus, function(j, o) {
					if(o.menuid == menuid){
						icon += o.icon;
					}
				 })
			})
			return icon;
		}
		
		login();
		InitLeftMenu();
		tabClose();
		tabCloseEven();
		$('#cp_ok').linkbutton({
			text:'确定',
			iconCls:'icon-ok'
		});
		$('#cp_cancel').linkbutton({
			text:'取消',
			iconCls:'icon-cancel'
		});
		$('#cp_ok').click(function() {
			if ($('#newpass').val() == $('#repass').val()){
				$.ajax({
					url: "/interface.php",
					async: true,
					type:'POST',
					dataType:'json',
					data:{type:'changepassword',oldpass:$('#oldpass').val(),newpass:$('#newpass').val()},
					success: function(msg){
						if (msg == 'success'){
							<?php
								if ($_REQUEST['lang'] == 'sc'){
									echo "$.messager.alert('成功','修改成功！');";
								}else if ($_REQUEST['lang'] == 'tc'){
									echo "$.messager.alert('成功','修改成功！');";
								}else{
									echo "$.messager.alert('成功','修改成功！');";
								}
							?>
							$("#oldpass").attr("value",'');
							$("#newpass").attr("value",'');
							$("#repass").attr("value",'');
							$('#editpass-win').window('close');
						}else{
							<?php
								if ($_REQUEST['lang'] == 'sc'){
									echo "$.messager.alert('失败','修改失败！');";
								}else if ($_REQUEST['lang'] == 'tc'){
									echo "$.messager.alert('失敗','修改失敗！');";
								}else{
									echo "$.messager.alert('失败','修改失败！');";
								}
							?>
							$("#oldpass").attr("value",'');
							$("#newpass").attr("value",'');
							$("#repass").attr("value",'');
						}
					},
					error:function(){
						<?php
							if ($_REQUEST['lang'] == 'sc'){
								echo "$.messager.alert('失败','修改失败！');";
							}else if ($_REQUEST['lang'] == 'tc'){
								echo "$.messager.alert('失敗','修改失敗！');";
							}else{
								echo "$.messager.alert('失败','修改失败！');";
							}
						?>
						$("#oldpass").attr("value",'');
						$("#newpass").attr("value",'');
						$("#repass").attr("value",'');
					}
				});
			}else{
				<?php
					if ($_REQUEST['lang'] == 'sc'){
						echo "$.messager.alert('警告','两次输入的新密码不一致');";
					}else if ($_REQUEST['lang'] == 'tc'){
						echo "$.messager.alert('警告','兩次輸入的新密碼不一致');";
					}else{
						echo "$.messager.alert('警告','两次输入的新密码不一致');";
					}
				?>
				$("#oldpass").attr("value",'');
				$("#newpass").attr("value",'');
				$("#repass").attr("value",'');
			}
			
		});
		$('#cp_cancel').click(function() {
			$('#editpass-win').window('close');
		});
		$('#editpass-win').window({
			collapsible:false,
			minimizable:false,
			maximizable:false,
			closable:true,
			closed:true,
			draggable:false,
			resizable:false,
			shadow:true,
			inline:false,
			modal:true
		});
		$('#oldpass').validatebox({  
			required:true
		});
		$('#newpass').validatebox({  
			required:true
		});
		$('#repass').validatebox({  
			required:true
		});
		$('#editpass').click(function() {
			$('#editpass-win').window({closed:false});
		});
		$('#login_ok').click(function() {
			$.ajax({
			  url: "/interface.php",
			  async: true,
			  type:'POST',
			  dataType:'json',
			  data:{type:'login',username:$('#username').val(),password:$('#password').val()},
			  success: function(msg){
				if (msg == 'success'){
					$('#login-win').window('close');
				}else{
					$.messager.alert('警告','账户或密码错误');
					$("#username").attr("value",'');
					$("#password").attr("value",'');
				}
			  }
			});
		});
		$('#logout').click(function() {
			$.messager.confirm('系统提示', '您确定要退出本次登录吗?', function(r) {
				if (r) {
					$.ajax({
					  url: "/interface.php",
					  async: true,
					  type:'POST',
					  dataType:'json',
					  data:{type:'logout'},
					  success: function(msg){
						if (msg == 'success'){
							location.href = '/admin/index.php';
						}
					  }
					});
				}
			});
		});
	});
	</script>
</head>
<body class="easyui-layout" style="overflow-y: hidden"  scroll="no">
	<noscript>
		<div style=" position:absolute; z-index:100000; height:2046px;top:0px;left:0px; width:100%; background:white; text-align:center;">
			<img src="images/noscript.gif" alt='抱歉，请开启脚本支持！' />
		</div>
	</noscript>
    <div region="north" split="true" border="false" style="overflow: hidden; height: 30px;
        background: url(images/layout-browser-hd-bg.gif) #7f99be repeat-x center 50%;
        line-height: 20px;color: #fff; font-family: Verdana, 微软雅黑,黑体">
        <span style="float:right; padding-right:20px;" class="head">欢迎 管理员 <a href="#" id="editpass">修改密码</a> <a href="#" id="logout">安全退出</a></span>
        <span style="padding-left:10px; font-size: 16px; "><img src="images/blocks.gif" width="20" height="20" align="absmiddle" /> 后台管理界面</span>
    </div>
    <div region="south" split="true" style="height: 30px; background: #D2E0F2; ">
        <div class="footer"><a href="http://www.media4studio.com">Media4Studio</a><a href="/admin/index.php?lang=sc" class="lan"  align="right">简体</a><a href="/admin/index.php?lang=tc" class="lan" align="right">繁体</a></div>
    </div>
    <div region="west" hide="true" split="true" title="导航菜单" style="width:180px;" id="west">
		<div id="west-menu" class="easyui-accordion" fit="true" border="false"></div>
	</div>
    <div id="mainPanle" region="center" style="background: #eee; overflow-y:hidden">
        <div id="tabs" class="easyui-tabs"  fit="true" border="false" >	
		</div>
    </div>
	<div id="login-win" title="登陆" icon="icon-sum"  style="width: 280px; height: 180px; padding: 5px;
        background: #fafafa;">
        <div class="easyui-layout" fit="true">
            <div region="center" border="false" style="padding: 10px; background: #fff; border: 1px solid #ccc;">
                <table cellpadding=3>
					<tr>
                        <td>账户：</td>
                        <td><input id="username" class="txt01" /></td>
                    </tr>
                    <tr>
                        <td>密码：</td>
                        <td><input id="password" type="Password" class="txt01" /></td>
                    </tr>
                </table>
            </div>
            <div region="south" border="false" style="text-align: right; height: 30px; line-height: 30px;">
                <a id="login_ok" href="#" ></a>
            </div>
        </div>
    </div>
	<div id="editpass-win" title="修改密码" icon="icon-save"  style="width: 300px; height: 210px; padding: 5px;
        background: #fafafa;">
        <div class="easyui-layout" fit="true">
            <div region="center" border="false" style="padding: 10px; background: #fff; border: 1px solid #ccc;">
                <table cellpadding=3>
					<tr>
                        <td>旧密码：</td>
                        <td><input id="oldpass" type="Password" class="txt01" /></td>
                    </tr>
                    <tr>
                        <td>新密码：</td>
                        <td><input id="newpass" type="Password" class="txt01" /></td>
                    </tr>
                    <tr>
                        <td>确认密码：</td>
                        <td><input id="repass" type="Password" class="txt01" /></td>
                    </tr>
                </table>
            </div>
            <div region="south" border="false" style="text-align: right; height: 30px; line-height: 30px;">
                <a id="cp_ok" href="#" ></a><a id="cp_cancel" href="#"></a>
            </div>
        </div>
    </div>
	<div id="mm" class="easyui-menu" style="width:150px;">
		<div id="mm-tabupdate">刷新</div>
		<div class="menu-sep"></div>
		<div id="mm-tabclose">关闭</div>
		<div id="mm-tabcloseall">全部关闭</div>
		<div id="mm-tabcloseother">除此之外全部关闭</div>
		<div class="menu-sep"></div>
		<div id="mm-tabcloseright">当前页右侧全部关闭</div>
		<div id="mm-tabcloseleft">当前页左侧全部关闭</div>
		<div class="menu-sep"></div>
		<div id="mm-exit">退出</div>
	</div>
</body>
</html>